package com.tywj.buscustomerapp.view.myview;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.TextView;

import com.tywj.buscustomerapp.Config;
import com.tywj.buscustomerapp.R;

public class TaylorPopupWindow extends AlertDialog{

    private TextView title;
    private TextView time;
    private TextView content;
    private TextView button;

    public TaylorPopupWindow(@NonNull Context context) {
        super(context);
    }

    public TaylorPopupWindow(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected TaylorPopupWindow(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.popuwindow_layout);
        title = findViewById(R.id.title);
        time = findViewById(R.id.time);
        content = findViewById(R.id.content);
        button = findViewById(R.id.button);
        WindowManager windowManager = getWindow().getWindowManager();
        int screenWidth = windowManager.getDefaultDisplay().getWidth();
        int screenHeight= windowManager.getDefaultDisplay().getHeight();
        WindowManager.LayoutParams attributes = getWindow().getAttributes();
        // 设置窗口背景透明度
        attributes.alpha = 1f;
        // 设置窗口宽高为屏幕的三分之一（为了更好地适配，请别直接写死）
        attributes.width = 4*screenWidth/5;
        attributes.height = 2*screenHeight/3;
        getWindow().setAttributes(attributes);
        getWindow().setWindowAnimations(R.style.take_photo_anim);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });


        initData();
    }

    private void initData() {
        content.setText(Html.fromHtml(Config.TEST));
    }
}
